package com.tvunetworks.center.user.controller.feign;

import com.tvunetworks.center.common.feign.customized.CustomizedUserFeignInterface;
import com.tvunetworks.center.common.model.dto.customizedcc.GroupUserAndRids;
import com.tvunetworks.center.user.service.CustomizedUserDeviceGroupService;
import com.tvunetworks.center.user.service.CustomizedUserGroupService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @program: tvucc-aggregator
 * @description: CustomizedUserFeignController
 * @author lebronchen
 * @create: 2020-04-15 08:56
 **/
@RestController
@RequestMapping("/feign/customized/user")
@Slf4j
public class CustomizedUserFeignController implements CustomizedUserFeignInterface {

    @Autowired
    private CustomizedUserGroupService customizedUserGroupService;
    @Autowired
    private CustomizedUserDeviceGroupService customizedUserDeviceGroupService;

    @Override
    public GroupUserAndRids getGroupUserAndRids(@RequestParam String group) {
        return customizedUserGroupService.getGroupUserAndRids(group);
    }

    @Override
    public List<String> listGroupRids(@RequestParam("groupName") String groupName) {
        return customizedUserDeviceGroupService.listGroupRids(groupName);
    }

    @Override
    public String getGroupNameById(@RequestParam("id") String id) {
        return customizedUserGroupService.getGroupNameById(id);
    }

    @Override
    public String getGroupNameByUserDevice(@RequestParam("userId") String userId, @RequestParam("peerId") String peerId) {
        return customizedUserDeviceGroupService.getUserDeviceGroupWithDefault(userId, peerId);
    }


}
